-- Filename：    MainUtil.lua
-- Author：      chengliang
-- Date：        2015-1-16
-- Purpose：     主界面工具类

module("MainItemFactory", package.seeall)

require "script/model/utils/ActivityConfigUtil"


local _itemArray = {}
--上部按钮
local SIGNIN        = 1     -- 签到
local ACTIVITY      = 2     -- 精彩活动
local EVERYDAY      = 3     -- 每日任务
local WORLD         = 4     -- 跨服争霸赛
local MISSION       = 5     -- 悬赏榜
local GUILD_WORLD   = 6     -- 军团世界战
local SEVENS_LOTTERY= 7     -- 七星台
local ONLINE        = 8     -- 在线奖励
local LEVE_REWARD   = 9     -- 等级礼包
local SERVER_GIFT   = 10     -- 开服礼包
local OPEN_ACT      = 11    -- 开服活动
local CARNIVAL      = 12    -- 节日狂欢
local REWARD_CENTER = 13    -- 领奖中心
local USER_UP       = 14    -- 临时账户
local PLAY_BACK     = 15    -- 重回三国
local REAL_NAME     = 16    -- 实名认证
local ANNIVER       = 17    -- 周年活动
local ANNIV_LOTTERY = 18    -- 周年抽奖
local RICH_GOD      = 19    -- 迎财神
local WORLD_CUP     = 20    -- 世界杯活动
local ANNIV_SIXTH   = 21    -- 六周年活动
local WARORDER      = 22    -- 战令系统
local ANNIVER_CAKE  = 23    -- 周年庆蛋糕摘出
local QUESTIONNAIRE = 24    -- 问卷调查
local SERVER_RANK   = 25    -- 新服排行
local ANNIV_EIGHTH  = 26    -- 八周年
local REGRESS       = 27    -- 回归有礼
local BEAUTY        = 28    -- 美人画卷
local ANNIV_NINETH  = 29    -- 九周年活动
local YUN_YING      = 30    -- 运营活动按钮
local ANNIV_TEN     = 31    -- 十周年活动
local LUCKY_FISH    = 32    -- 幸运锦鲤
local ANNIV_ELEVEN  = 33    -- 11周年活动
local DIRECT_ACT       = 34    -- 直购活动合集
-- local TIME_BAG      = 33    -- 限时等级礼包

--中部按钮
local RES_RECOVER      = 51 --资源追回
local CITY_WAR         = 52 --城池战
local GUILD_INVITE     = 53 --军团副本邀请
local TOWER_MYSTERIOUS = 54 --试炼塔神秘层
local ROB_BATTLE       = 55 --抢粮战按钮
local COUNTRY_WAR      = 56 --国战
local RED_PACKAGEG     = 57 --红包
local HORSE_INVITE     = 58 --木牛流马协助邀请
local TITLE_DISAPPEAR  = 59 --装备称号失效
local RES_TREAS        = 60 --资源库宝藏
local RES_EMPTY        = 61 --资源矿空旷提示
local COMPETE          = 62 --逐鹿中原
local CROSS_RES_EMPTY  = 63 --跨服资源矿空旷
local WORLD_TEAM_INVITE= 64 --跨服组队战邀请
local BATTLE_RANK_FIGHT= 65 --跨服排位赛匹配阶段快速入口
local ANNIVER_FIFTH    = 66 --五周年活动
local ANNIVER_SEVENTH  = 67 --七周年活动
local KFLT_EMPTY_POS   = 68 --跨服擂台塞空位置
local HERO_BEAUTY      = 69 --美人旅游
-- local WEB_VIEW         = 62 --内置浏览器

-- 添加一键扫荡测试按钮
local TEST_BUTTON      = 100

--下部按钮
local STARHERO      = 101--名将
local HERO          = 102--武将
local EQUIP         = 103--装备
local ASTROLOGY     = 104--占星
local DESTINY       = 105--天命
local FIGHTSOUL     = 106--战魂
local RECYCLE       = 107--炼化炉
local GUILD         = 108--军团
local PET           = 109--宠物
local CHAT          = 110--聊天
local OTHER         = 111--功能
local SHOP          = 112--商店



function getBottomBtnPos()
    local pos = {}
    pos[STARHERO]  = ccp(65,234)
    pos[HERO]      = ccp(170,234)
    pos[EQUIP]     = ccp(270,234)
    pos[ASTROLOGY] = ccp(376,234)
    pos[DESTINY]   = ccp(477,234)
    pos[FIGHTSOUL] = ccp(575,234)
    pos[SHOP]      = ccp(65,86)
    pos[RECYCLE]   = ccp(170,86)
    pos[GUILD]     = ccp(270,86)
    pos[PET]       = ccp(376,86)
    pos[CHAT]      = ccp(477,86)
    pos[OTHER]     = ccp(575,86)
    return pos
end

function getMiddleBtnArray()
    local btnAttay = {
        RES_RECOVER,
        CITY_WAR,
        GUILD_INVITE,
        TOWER_MYSTERIOUS,
        ROB_BATTLE,
        COUNTRY_WAR,
        RED_PACKAGEG,
        HORSE_INVITE,
        TITLE_DISAPPEAR,
        RES_TREAS,
        RES_EMPTY,
        COMPETE,
        CROSS_RES_EMPTY,
        WORLD_TEAM_INVITE,
        BATTLE_RANK_FIGHT,
        KFLT_EMPTY_POS,
        HERO_BEAUTY,
        TEST_BUTTON,--扫荡测试按钮
        -- WEB_VIEW
    }
    return btnAttay
end

function getTopBtnAarray()
    local btnAttay = {
        SIGNIN,
        ACTIVITY,
        EVERYDAY,
        WORLD,
        MISSION,
        SEVENS_LOTTERY,
        GUILD_WORLD,
        SERVER_GIFT,
        ONLINE,
        OPEN_ACT,
        CARNIVAL,
        LEVE_REWARD,
        REWARD_CENTER,
        USER_UP,
        PLAY_BACK,
        REAL_NAME,
        ANNIVER,
        ANNIVER_CAKE,
        ANNIV_LOTTERY,
        RICH_GOD,
        WORLD_CUP,
        ANNIVER_FIFTH,
        ANNIV_SIXTH,
        WARORDER,
        QUESTIONNAIRE,
        SERVER_RANK,
        ANNIVER_SEVENTH,
        ANNIV_EIGHTH,
        REGRESS,
        BEAUTY,
        ANNIV_NINETH,
        YUN_YING,
        ANNIV_TEN,
        LUCKY_FISH,
        ANNIV_ELEVEN,
        DIRECT_ACT,
        -- TIME_BAG,

    }
    return btnAttay
end

function getButtonCreateArray()
    return _itemArray
end

--↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓添加一键扫荡脚本↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
--一键扫荡测试按钮
_itemArray[TEST_BUTTON] = {}
_itemArray[TEST_BUTTON].createButton = function ( ... )
   --require "script/model/DataCache"
   local item= CCMenuItemImage:create("images/common/soul_sd_n.png", "images/common/soul_sd_h.png")
   item:registerScriptTapHandler(_itemArray[TEST_BUTTON].actionCallback)
   local button = createButtonWithItem(item)
   return button
end
_itemArray[TEST_BUTTON].actionCallback = function ( ... )
   require "script/ui/main/SweepAllLayer"
   SweepAllLayer.initLayer()
   --SweepAll.sweep()
end
_itemArray[TEST_BUTTON].isShow = function ( ... )
   return true
end
--↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑添加一键扫荡脚本↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

--名将按钮
_itemArray[STARHERO] = {}
_itemArray[STARHERO].createButton = function ( ... )
    local norImg = "images/main/sub_icons/fair_n.png"
    local higImg = "images/main/sub_icons/fair_h.png"
    local item = createButton(norImg, higImg, _itemArray[STARHERO].actionCallback)
    --小红点
    require "script/ui/star/StarUtil"
    local isShowTip = StarUtil.isHaveTip()
    showTipSprite(menuItem,isShowTip)
    return item
end
_itemArray[STARHERO].actionCallback = function ( ... )
    require "script/guide/NewGuide"
    if(NewGuide.guideClass == ksGuideGreatSoldier) then
        require "script/guide/StarHeroGuide"
        StarHeroGuide.changLayer()
    end
    require "script/guide/NewGuide"
    if(NewGuide.guideClass == ksGuideHeroBiography) then
        require "script/guide/LieZhuanGuide"
        LieZhuanGuide.changLayer()
    end
    if not DataCache.getSwitchNodeState(ksSwitchGreatSoldier) then
        return
    end
    require "script/ui/star/StarLayer"
    local starLayer = StarLayer.createLayer()
    MainScene.changeLayer(starLayer, "starLayer")
end

--武将将按钮
_itemArray[HERO] = {}
_itemArray[HERO].createButton = function ( ... )
    local norImg = "images/main/sub_icons/hero_n.png"
    local higImg = "images/main/sub_icons/hero_h.png"
    local item = createButton(norImg, higImg, _itemArray[HERO].actionCallback)
    --小红点
    require "script/model/hero/HeroModel"
    HeroModel.initNewHero()
    if(HeroModel.isHaveNewHero() == true) then
        local newAnimSprite = XMLSprite:create("images/mail/new/new")
        newAnimSprite:setPosition(ccp(item:getContentSize().width*0.5-20,item:getContentSize().height-20))
        item:addChild(newAnimSprite,3)
    end
    require "script/ui/hero/HeroSoulLayer"
    print(GetLocalizeStringBy("key_1097"), HeroSoulLayer.getFuseSoulNum())
    if(HeroSoulLayer.getFuseSoulNum() > 0) then
        local tipSprite = CCSprite:create("images/common/tip_2.png")
        tipSprite:setAnchorPoint(ccp(0.5, 0.5))
        tipSprite:setPosition(ccpsprite(0.85,0.85, item))
        item:addChild(tipSprite)
    end
    return item
end
_itemArray[HERO].actionCallback = function ( ... )
    require "script/guide/NewGuide"
    if(NewGuide.guideClass ==  ksGuideForge) then
        require "script/guide/StrengthenGuide"
        StrengthenGuide.changLayer()
    end
    require "script/guide/NewGuide"
    require "script/guide/GeneralUpgradeGuide"
    if(NewGuide.guideClass ==  ksGuideGeneralUpgrade) then
        GeneralUpgradeGuide.changeLayer()
    end
    require "script/guide/NewGuide"
    if(NewGuide.guideClass == ksGuideHeroDevelop) then
        require "script/guide/HeroDevelopGuide"
        HeroDevelopGuide.changLayer()
    end
    if not DataCache.getSwitchNodeState(ksSwitchGeneralTransform) then
        return
    end
	require "script/ui/hero/HeroLayer"
    MainScene.changeLayer(HeroLayer.createLayer(), "HeroLayer")
end

--装备按钮
_itemArray[EQUIP] = {}
_itemArray[EQUIP].createButton = function ( ... )
    local norImg = "images/main/sub_icons/equip_n.png"
    local higImg = "images/main/sub_icons/equip_h.png"
    local item = createButton(norImg, higImg, _itemArray[EQUIP].actionCallback)
    --小红点
    local isShowTip = BagUtil.isShowTipSprite()
    showTipSprite(item,isShowTip)
    return item
end
_itemArray[EQUIP].actionCallback = function ( ... )
    require "script/ui/bag/BagLayer"
    local bagLayer = BagLayer.createLayer(BagLayer.Tag_Init_Arming)
    MainScene.changeLayer(bagLayer, "bagLayer")
end

--占星
_itemArray[ASTROLOGY] = {}
_itemArray[ASTROLOGY].createButton = function ( ... )
    local norImg = "images/main/sub_icons/horoscope_n.png"
    local higImg = "images/main/sub_icons/horoscope_h.png"
    local item = createButton(norImg, higImg, _itemArray[ASTROLOGY].actionCallback)
    --小红点
    local alertSprite = CCSprite:create("images/common/tip_2.png")
    alertSprite:setAnchorPoint(ccp(0.5,0.5))
    alertSprite:setPosition(ccp(item:getContentSize().width*0.8,item:getContentSize().height*0.8))
    item:addChild(alertSprite,1,1915)
    alertSprite:setVisible(_isAstroAlert)
    return item
end
_itemArray[ASTROLOGY].actionCallback = function ( ... )
    require "script/guide/NewGuide"
    if(NewGuide.guideClass == ksGuideAstrology) then
        require "script/guide/AstrologyGuide"
        AstrologyGuide.changLayer()
    end
    if not DataCache.getSwitchNodeState(ksSwitchStar) then
        return
    end
    require "script/ui/astrology/AstrologyLayer"
    local astrologyLayer = AstrologyLayer.createAstrologyLayer()
    MainScene.changeLayer(astrologyLayer, "AstrologyLayer",AstrologyLayer.exitAstro)
end

--天命
_itemArray[DESTINY] = {}
_itemArray[DESTINY].createButton = function ( ... )
    local norImg = "images/main/sub_icons/destiny_n.png"
    local higImg = "images/main/sub_icons/destiny_h.png"
    local item = createButton(norImg, higImg, _itemArray[DESTINY].actionCallback)
    --武将学技能小红点
    require "script/ui/replaceSkill/ReplaceSkillData"
    local isShowTip = ReplaceSkillData.isShowTip()
    showTipSprite(item, isShowTip)
    --天命小红点
    if DataCache.getSwitchNodeState(ksSwitchDestiny, false) then
        require "script/ui/destiny/DestinyData"
        if DestinyData.canUpDestiny() then
            local alertSprite = CCSprite:create("images/common/tip_2.png")
            alertSprite:setAnchorPoint(ccp(0.5,0.5))
            alertSprite:setPosition(ccp(item:getContentSize().width*0.8,item:getContentSize().height*0.8))
            item:addChild(alertSprite,1,1998)
        end
    end
    return item
end
_itemArray[DESTINY].actionCallback = function ( ... )
    require "script/guide/NewGuide"
    if(NewGuide.guideClass == ksGuideDestiny) then
        require "script/guide/DestinyGuide"
        DestinyGuide.changLayer()
    end
    require "script/guide/NewGuide"
    if(NewGuide.guideClass == ksGuideChangeSkill) then
        require "script/guide/ChangeSkillGuide"
        ChangeSkillGuide.changLayer()
    end
    if not DataCache.getSwitchNodeState(ksSwitchDestiny) then
        return
    end
    require "script/ui/destiny/DestinyLayer"
    local destinyLayer = DestinyLayer.createLayer()
    MainScene.changeLayer(destinyLayer, "destinyLayer")
end

--战魂
_itemArray[FIGHTSOUL] = {}
_itemArray[FIGHTSOUL].createButton = function ( ... )
    local norImg = "images/main/sub_icons/fightSoul_n.png"
    local higImg = "images/main/sub_icons/fightSoul_h.png"
    local item = createButton(norImg, higImg, _itemArray[FIGHTSOUL].actionCallback)
    return item
end
_itemArray[FIGHTSOUL].actionCallback = function ( ... )
    -- 战魂入口
    if not DataCache.getSwitchNodeState(ksSwitchBattleSoul) then
        return
    end
    require "script/ui/huntSoul/HuntSoulLayer"
    local layer = HuntSoulLayer.createHuntSoulLayer()
    MainScene.changeLayer(layer, "huntSoulLayer")
    
end

--商店
_itemArray[SHOP] = {}
_itemArray[SHOP].createButton = function ( ... )
    local norImg = "images/main/sub_icons/shop_n.png"
    local higImg = "images/main/sub_icons/shop_h.png"
    local item = createButton(norImg, higImg, _itemArray[FIGHTSOUL].actionCallback)
    return item
end
_itemArray[SHOP].actionCallback = function ( ... )
    require "script/ui/shopall/ShoponeLayer"
    ShoponeLayer.show()
end

--炼化炉
_itemArray[RECYCLE] = {}
_itemArray[RECYCLE].createButton = function ( ... )
    local norImg = "images/main/sub_icons/recycle_n.png"
    local higImg = "images/main/sub_icons/recycle_h.png"
    local item = createButton(norImg, higImg, _itemArray[RECYCLE].actionCallback)
    return item
end
_itemArray[RECYCLE].actionCallback = function ( ... )
    require "script/guide/NewGuide"
    require "script/guide/ResolveGuide"
    if(NewGuide.guideClass ==  ksGuideResolve and ResolveGuide.stepNum == 1) then
        ResolveGuide.changLayer()
    end
    if not DataCache.getSwitchNodeState(ksSwitchResolve) then
        return
    end
    require "script/ui/refining/RefiningMainLayer"
    RefiningMainLayer.createLayer(true)
end

--军团
_itemArray[GUILD] = {}
_itemArray[GUILD].createButton = function ( ... )
    local norImg = "images/main/sub_icons/guild_n.png"
    local higImg = "images/main/sub_icons/guild_h.png"
    local item = createButton(norImg, higImg, _itemArray[GUILD].actionCallback)
    require "script/ui/guild/GuildDataCache"
    if( GuildDataCache.getIsShowRedTip() )then
        local alertSprite = CCSprite:create("images/common/tip_2.png")
        alertSprite:setAnchorPoint(ccp(0.5,0.5))
        alertSprite:setPosition(ccp(item:getContentSize().width*0.8,item:getContentSize().height*0.8))
        item:addChild(alertSprite,1,1998)
    end
    return item
end
_itemArray[GUILD].actionCallback = function ( ... )
    -- 军团入口
    if not DataCache.getSwitchNodeState(ksSwitchGuild) then
        return
    end
    -- 设置小红圈false
    GuildDataCache.setIsShowRedTip(false)
    require "script/ui/guild/GuildImpl"
    GuildImpl.showLayer()
end

--宠物
_itemArray[PET] = {}
_itemArray[PET].createButton = function ( ... )
    local norImg = "images/main/sub_icons/pet_n.png"
    local higImg = "images/main/sub_icons/pet_h.png"
    local item = createButton(norImg, higImg, _itemArray[PET].actionCallback)
    --宠物小红点
    require "script/ui/pet/PetData"
    if PetData.isShowTip() or PetData.productTip() then
        local alertSprite = CCSprite:create("images/common/tip_2.png")
        alertSprite:setAnchorPoint(ccp(0.5,0.5))
        alertSprite:setPosition(ccp(item:getContentSize().width*0.8,item:getContentSize().height*0.8))
        item:addChild(alertSprite,1,1998)
    end
    return item
end
_itemArray[PET].actionCallback = function ( ... )
    require "script/guide/NewGuide"
    if(NewGuide.guideClass == ksGuidePet) then
        require "script/guide/PetGuide"
        PetGuide.changLayer()
    end
    if not DataCache.getSwitchNodeState(ksSwitchPet) then
        return
    end
    require "script/ui/pet/PetMainLayer"
    local layer= PetMainLayer.createLayer()
    MainScene.changeLayer(layer, "PetMainLayer")
end

--聊天
_itemArray[CHAT] = {}
_itemArray[CHAT].createButton = function ( ... )
    local norImg = "images/main/sub_icons/chat_n.png"
    local higImg = "images/main/sub_icons/chat_h.png"
    local item = createButton(norImg, higImg, _itemArray[PET].actionCallback)

    local animSprite = XMLSprite:create("images/base/effect/chat/liaotian")
    animSprite:setAnchorPoint(ccp(0.5,0.5))
    animSprite:setPosition(ccp(item:getContentSize().width*0.52,item:getContentSize().height*0.55))
    item:addChild(animSprite,1,1911)
    animSprite:setVisible(_isShowChatAnimation)

    -- 私人聊天的提示 , added by zhz
    local pChatTipSp= CCSprite:create("images/common/tip_2.png")
    pChatTipSp:setAnchorPoint(ccp(1,1))
    pChatTipSp:setPosition(ccp(item:getContentSize().width*0.97 ,item:getContentSize().height*0.98))
    item:addChild(pChatTipSp,1,1914)
    require "script/ui/chat/ChatMainLayer"
    pChatTipSp:setVisible(ChatMainLayer.getNewPmCount() > 0)
    return item
end
_itemArray[CHAT].actionCallback = function ( ... )
    require "script/ui/chat/ChatMainLayer"
    ChatMainLayer.showChatLayer()
end


--功能按钮
_itemArray[OTHER] = {}
_itemArray[OTHER].createButton = function ( ... )
    require "script/ui/main/FunctionButtonUtil"
    local item = FunctionButtonUtil.createButton()
    --设置z轴
    _itemArray[OTHER].zOrder = 300
    return item
end


--签到
_itemArray[SIGNIN] = {}
_itemArray[SIGNIN].createButton = function ( ... )
    require "script/ui/sign/SignRewardLayer"
    require "script/ui/sign/SignRewardController"
    local item = CCMenuItemImage:create("images/sign/sign/sign_n.png","images/sign/sign/sign_h.png")
    item:setAnchorPoint(ccp(0, 1))
    -- 小红点
    require "script/utils/ItemDropUtil"
    _itemArray[SIGNIN].tipSprite = ItemDropUtil.getTipSpriteByNum()
    _itemArray[SIGNIN].tipSprite:setPosition(ccp(item:getContentSize().width*0.97, item:getContentSize().height*0.98))
    _itemArray[SIGNIN].tipSprite:setAnchorPoint(ccp(1,1))
    _itemArray[SIGNIN].tipSprite:setVisible(false)
    item:addChild(_itemArray[SIGNIN].tipSprite, 1)
    
    -- 若有奖励可以领取，则开启特效
    require "script/ui/sign/SignRewardData"
    local isCanRecieve = SignRewardData.isCanRecieveSignRewarde()
    if isCanRecieve == true then
        local img_path = CCString:create("images/sign/qiandao/qiandao") 
        _itemArray[SIGNIN].signEffect = XMLSprite:create("images/sign/qiandao/qiandao")
        _itemArray[SIGNIN].signEffect:setPosition(ccp(item:getContentSize().width*0.5,item:getContentSize().height*0.5))
        _itemArray[SIGNIN].signEffect:setAnchorPoint(ccp(0.5,0.5))
        item:addChild(_itemArray[SIGNIN].signEffect)
        _itemArray[SIGNIN].tipSprite:setVisible(true)
    end
    
    item:registerScriptTapHandler(_itemArray[SIGNIN].actionCallback)
    _itemArray[SIGNIN].item = item
    local button = createButtonWithItem(item)
    return button
end
_itemArray[SIGNIN].actionCallback = function ()
    if _itemArray[SIGNIN].signButtonClickCallback ~= nil then
        _itemArray[SIGNIN].signButtonClickCallback()
    end
    local canEnter = DataCache.getSwitchNodeState(ksSwitchSignIn)
    if canEnter then
        AudioUtil.playEffect("audio/effect/zhujiemian.mp3")
        SignRewardLayer.showLayer()
    end
end
_itemArray[SIGNIN].registerSignButtonClickCallback = function (pCallBack)
    _itemArray[SIGNIN].signButtonClickCallback = pCallBack
end
_itemArray[SIGNIN].isShow = function ()
    return true
end


--精彩活动
_itemArray[ACTIVITY] = {}
_itemArray[ACTIVITY].createButton = function ( ... )
    local norImg = "images/main/sub_icons/highlights_n.png"
    local higImg = "images/main/sub_icons/highlights_h.png"
    local item = CCMenuItemImage:create(norImg, higImg)
    item:setAnchorPoint(ccp(0.5, 0.5))
    item:registerScriptTapHandler(_itemArray[ACTIVITY].actionCallback)
    local button = createButtonWithItem(item)
    _itemArray[ACTIVITY].item = item
    _itemArray[ACTIVITY].update()
    return button
end
_itemArray[ACTIVITY].actionCallback = function ( ... )
    require "script/ui/rechargeActive/RechargeActiveMain"
    AudioUtil.playEffect("audio/effect/zhujiemian.mp3")
    local layer = RechargeActiveMain.create()
    MainScene.changeLayer(layer, "layer")
end
_itemArray[ACTIVITY].update = function ( ... )
    local item = _itemArray[ACTIVITY].item
    if item.tipSprite then
        item.tipSprite:removeFromParentAndCleanup(true)
        item.tipSprite = nil
    end
    --小红点
    require "script/ui/rechargeActive/ActiveCache"
    if ActiveCache.hasTipInActive() then
        require "script/utils/ItemDropUtil"
        local tipSprite= CCSprite:create("images/common/tip_2.png")
        tipSprite:setPosition(ccp(item:getContentSize().width*0.97, item:getContentSize().height*0.98))
        tipSprite:setAnchorPoint(ccp(1,1))
        item:addChild(tipSprite,1)
        item.tipSprite = tipSprite
        print("add activity tip sprite")
    end
    --成长之路tip文字提示
    local lvFun = function ( ... )
        local tipDes = "成长之路享好礼!"
        local tipBgSprite = CCScale9Sprite:create(CCRectMake(68,20,20,20),"images/main/btn_tip_11.png")
        tipBgSprite:setAnchorPoint(ccp(0.7, 0.1))
        tipBgSprite:setPosition(ccpsprite(0.8, 0.7, item))
        item:addChild(tipBgSprite,100)

        local tipLabel = CCRenderLabel:create(tipDes, g_sFontName, 25, 1, ccc3(0x35,0x0e, 0x0e), type_shadow)
        tipLabel:setAnchorPoint(ccp(0.5, 1))
        tipLabel:setPosition(tipBgSprite:getContentSize().width/2, tipBgSprite:getContentSize().height - 20)
        tipBgSprite:addChild(tipLabel)

        tipBgSprite:setScale(0)
        local lvarray = CCArray:create()
        lvarray:addObject(CCDelayTime:create(1))
        lvarray:addObject(CCScaleTo:create(0.5, 1.3))
        lvarray:addObject(CCScaleTo:create(0.2, 0.8))
        lvarray:addObject(CCScaleTo:create(0.1, 1))
        lvarray:addObject(CCDelayTime:create(5))
        lvarray:addObject(CCScaleTo:create(0.2, 0))
        local action = CCSequence:create(lvarray)
        tipBgSprite:runAction(action)
    end
   
    --tip文字提示
    local tipDes = ActiveCache.getActivBtnTipDes()
    if tipDes then
        local tipBgSprite = CCScale9Sprite:create(CCRectMake(68,20,20,20),"images/main/btn_tip_9.png")
        tipBgSprite:setAnchorPoint(ccp(0.7, 0.1))
        tipBgSprite:setPosition(ccpsprite(0.8, 0.7, item))
        item:addChild(tipBgSprite,100)

        local tipLabel = CCRenderLabel:create(tipDes, g_sFontName, 25, 1, ccc3(0x35,0x0e, 0x0e), type_shadow)
        tipLabel:setAnchorPoint(ccp(0.5, 1))
        tipLabel:setPosition(tipBgSprite:getContentSize().width/2, tipBgSprite:getContentSize().height - 20)
        tipBgSprite:addChild(tipLabel)

        tipBgSprite:setScale(0)
        local array = CCArray:create()
        array:addObject(CCDelayTime:create(1))
        array:addObject(CCScaleTo:create(0.5, 1.3))
        array:addObject(CCScaleTo:create(0.2, 0.8))
        array:addObject(CCScaleTo:create(0.1, 1))
        array:addObject(CCDelayTime:create(5))
        array:addObject(CCScaleTo:create(0.2, 0))
        --飘完大礼包 再飘成长之路的重置
        array:addObject(CCCallFunc:create(lvFun))
        local action = CCSequence:create(array)
        tipBgSprite:runAction(action)
    else
        lvFun()
    end
end
_itemArray[ACTIVITY].isShow = function ( ... )
    return true
end

--每日任务
_itemArray[EVERYDAY] = {}
_itemArray[EVERYDAY].createButton = function ( ... )
    local norImg = "images/main/sub_icons/everyday_n.png"
    local higImg = "images/main/sub_icons/everyday_h.png"
    local item = CCMenuItemImage:create(norImg, higImg)
    item:setAnchorPoint(ccp(0.5, 0.5))
    item:registerScriptTapHandler(_itemArray[EVERYDAY].actionCallback)
    _itemArray[EVERYDAY].item = item
    _itemArray[EVERYDAY].update()
    local button = createButtonWithItem(item)
    return button
end
_itemArray[EVERYDAY].actionCallback = function ( ... )
    -- -- 每日任务入口
    if not DataCache.getSwitchNodeState(ksSwitchEveryDayTask) then
        return
    end 
    require "script/ui/everyday/EverydayLayer"
    EverydayLayer.showEverydayLayer()
end
_itemArray[EVERYDAY].update = function ( ... )
    local item = _itemArray[EVERYDAY].item
    if item.tipSprite then
        item.tipSprite:removeFromParentAndCleanup(true)
        item.tipSprite = nil
    end
    require "script/ui/everyday/EverydayData"
    local isShowTip = EverydayData.getIsShowTipSprite()
    local tipSprite = CCSprite:create("images/common/tip_2.png")
    tipSprite:setAnchorPoint(ccp(0.5,0.5))
    tipSprite:setPosition(ccp(item:getContentSize().width*0.8,item:getContentSize().height*0.8))
    item:addChild(tipSprite,1,1915)
    tipSprite:setVisible(isShowTip)
    item.tipSprite = tipSprite
end
_itemArray[EVERYDAY].isShow = function ( ... )
    return true
end

--悬赏榜
_itemArray[MISSION] = {}
_itemArray[MISSION].createButton = function ( ... )
    require "script/ui/rewardtask/RewardTaskButtonUtil"
    local button = RewardTaskButtonUtil.createButton()
    _itemArray[MISSION].zOrder = 500
    return button
end
_itemArray[MISSION].isShow = function ( ... )
    require "script/ui/mission/MissionMainData"
     require "script/ui/rewardtask/RewardTaskData"
    if MissionMainData.isCanJion() and MissionMainData.getTeamId() >0 or RewardTaskData.isOpen() then
        -- print("2222200000++++===")
        return true
    else
         -- print("2222200000++++===false")
        return false
    end
   
    
    
end

-- _itemArray[MISSION] = {}
-- _itemArray[MISSION].createButton = function ( ... )
--     local norImg = "images/main/sub_icons/mission_btn_n.png"
--     local higImg = "images/main/sub_icons/mission_btn_h.png"
--     local item = CCMenuItemImage:create(norImg, higImg)
--     item:setAnchorPoint(ccp(0.5, 0.5))
--     item:registerScriptTapHandler(_itemArray[MISSION].actionCallback)


--     _itemArray[MISSION].item = item
--     _itemArray[MISSION].update()
--     local button = createButtonWithItem(item)
--     return button
-- end
-- _itemArray[MISSION].actionCallback = function ( ... )
--     -- 悬赏榜入口
--     require "script/ui/mission/MissionMainLayer"
--     MissionMainLayer.showLayer()
-- end
-- _itemArray[MISSION].update = function ( ... )
--     --闪光特效
--     local item = _itemArray[MISSION].item
--     if item.effect then
--         item.effect:removeFromParentAndCleanup(true)
--         item.effect = nil
--     end
--     local effect = XMLSprite:create("images/base/effect/xuanshangbangtubiao/xuanshangbangtubiao")
--     effect:setPosition(ccpsprite(0.5, 0.5, item))
--     item:addChild(effect)
--     effect:setVisible(false)
--     item.effect = item.effect
--     require "script/ui/mission/MissionMainData"
--     if MissionMainData.isCanDonate() then
--         effect:setVisible(true)
--     end
--     --小红点
--     if item.tipSprite then
--         item.tipSprite:removeFromParentAndCleanup(true)
--         item.tipSprite = nil
--     end
--     local isShowTip = MissionMainData.isShowRedTip()
--     local tipSprite = CCSprite:create("images/common/tip_2.png")
--     tipSprite:setAnchorPoint(ccp(0.5,0.5))
--     tipSprite:setPosition(ccp(item:getContentSize().width*0.8,item:getContentSize().height*0.8))
--     item:addChild(tipSprite,1,1915)
--     tipSprite:setVisible(isShowTip)
--     item.tipSprite = tipSprite
-- end
-- _itemArray[MISSION].isShow = function ( ... )
--     require "script/ui/mission/MissionMainData"
--     if MissionMainData.isCanJion() and MissionMainData.getTeamId() >0 then
--         return true
--     end
--     return false
-- end
--军团世界战
_itemArray[GUILD_WORLD] = {}
_itemArray[GUILD_WORLD].createButton = function ( ... )
    local norImg = "images/main/sub_icons/guild_world_n.png"
    local higImg = "images/main/sub_icons/guild_world_h.png"
    local item = CCMenuItemImage:create(norImg, higImg)
    item:setAnchorPoint(ccp(0.5, 0.5))
    item:registerScriptTapHandler(_itemArray[GUILD_WORLD].actionCallback)
    _itemArray[GUILD_WORLD].item = item
    local button = createButtonWithItem(item)
    _itemArray[GUILD_WORLD].update()
    
   

    return button
end

_itemArray[GUILD_WORLD].isShow = function ( ... )
    -- 判断是否有军团
    -- require "script/ui/guild/GuildDataCache"
    -- local guildId = GuildDataCache.getMineSigleGuildId()
    -- local haveGuild = true
    -- if(guildId == 0)then
    --     haveGuild = false
    -- end

    return DataCache.getSwitchNodeState(ksSwitchWorldPeople,false) --and haveGuild
end
_itemArray[GUILD_WORLD].update = function ( ... )
   local item = _itemArray[GUILD_WORLD].item
    if item.tipSprite then
        item.tipSprite:removeFromParentAndCleanup(true)
        item.tipSprite = nil
    end
    -- 判断是否有军团
    require "script/ui/guild/GuildDataCache"
    local guildId = GuildDataCache.getMineSigleGuildId()
    local haveGuild = true
    if(guildId == 0)then
        haveGuild = false
    end

    if DataCache.getSwitchNodeState(ksSwitchWorldPeople,false) and haveGuild then
        local getWorldArmyInfo = CityData.getWorldArmyInfo()
        require "script/ui/copy/worldReward/WorldRewardData"
        local isShowTip = (not table.isEmpty(getWorldArmyInfo.army)) or WorldRewardData.redState()
        -- print("GUILD_WORLD isShowTip",isShowTip)
        local tipSprite = CCSprite:create("images/common/tip_2.png")
        tipSprite:setAnchorPoint(ccp(0.5,0.5))
        tipSprite:setPosition(ccp(item:getContentSize().width*0.8,item:getContentSize().height*0.8))
        item:addChild(tipSprite,1,1915)
        tipSprite:setVisible(isShowTip)
        item.tipSprite = tipSprite
    end
end
_itemArray[GUILD_WORLD].actionCallback = function ( ... )
    -- 军团世界战入口
    -- 判断是否有军团
    require "script/ui/guild/GuildDataCache"
    local guildId = GuildDataCache.getMineSigleGuildId()
    local haveGuild = true
    if(guildId == 0)then
        AnimationTip.showTip(GetLocalizeStringBy("key_1043"))
        return
    end

    local hallLv,userLv = CityData.getLimitForCityWar()
    local my_userLv = UserModel.getHeroLevel()
    local my_hallLv = GuildDataCache.getGuildHallLevel()
    if(my_userLv < userLv and my_hallLv < hallLv)then
        local str = GetLocalizeStringBy("lic_1114") .. hallLv .. GetLocalizeStringBy("lic_1115") .. userLv .. GetLocalizeStringBy("lic_1116")
        AnimationTip.showTip(str)
        return
    elseif(my_userLv < userLv)then
        local str = GetLocalizeStringBy("lic_1117") .. userLv .. GetLocalizeStringBy("lic_1116")
        AnimationTip.showTip(str)
        return
    elseif(my_hallLv < hallLv)then
        local str = GetLocalizeStringBy("lic_1118") .. hallLv .. GetLocalizeStringBy("lic_1116")
        AnimationTip.showTip(str)
        return
    end

    require "script/ui/copy/BigMap"
    local fortsLayer = BigMap.createFortsLayout(function ( ... )
          require "script/ui/main/MainBaseLayer"
        local main_base_layer = MainBaseLayer.create()
        MainScene.changeLayer(main_base_layer, "main_base_layer",MainBaseLayer.exit)
        MainScene.setMainSceneViewsVisible(true,true,true)
    end)
    MainScene.changeLayer(fortsLayer, "BigMap")
end

--七星台（实际上是 点将台 = 七星台+名将台+铜雀台，只开了一个就是那个，否则复合菜单）
local hasSeven
local hasHero
local hasBeauty
_itemArray[SEVENS_LOTTERY] = {}
_itemArray[SEVENS_LOTTERY].createButton = function ( ... )
    require "script/ui/herorepl/platform/HeroReplPlfData"
    require "script/ui/sevenlottery/SevenLotteryData"
    require "script/ui/rechargeActive/beautyLottery/BeautyLotteryData"
    require "script/ui/reserve/ReArmyData"
    hasSeven = SevenLotteryData.isShow()
    hasHero = HeroReplPlfData.isOpenPlfHero()
    hasBeauty = BeautyLotteryData.isUnlocked()
    hasReBtn = ReArmyData.isUnlocked()
    -- Logger.tip("七星台、名将台、铜雀台开启情况：")
    -- print_t({hasSeven,hasHero,hasBeauty})
    --如果只开启了 后军 只显示后军按钮
    if hasReBtn and (not hasSeven) and (not hasHero) and (not hasBeauty) then
        local norImg = "images/main/sub_icons/houjuntai_n.png"
        local higImg = "images/main/sub_icons/houjuntai_h.png"
        local item = CCMenuItemImage:create(norImg, higImg)
        item:setAnchorPoint(ccp(0.5, 0.5))
        item:registerScriptTapHandler(_itemArray[SEVENS_LOTTERY].actionCallback)
        _itemArray[SEVENS_LOTTERY].item = item
        local button = createButtonWithItem(item)
        return button
    else
        require "script/ui/herorepl/platform/HeroReplPlfButtonUtil"
        local button = HeroReplPlfButtonUtil.createButton()
        _itemArray[SEVENS_LOTTERY].zOrder = 600
        return button
    end
end

_itemArray[SEVENS_LOTTERY].isShow = function ( ... )
    require "script/ui/reserve/ReArmyData"
    if ReArmyData.isUnlocked() then
        return true
    end
    return false
end
_itemArray[SEVENS_LOTTERY].actionCallback = function ( ... )
    if hasReBtn and (not hasSeven) and (not hasHero) and (not hasBeauty) then
        -- 七星台入口
        require "script/ui/reserve/ReArmyMainLayer"
        ReArmyMainLayer.showLayer()
    else
        -- Logger.tip("展开台子复合菜单")
    end
end

--账户升级
_itemArray[USER_UP] = {}
_itemArray[USER_UP].createButton = function ( ... )
    local norImg = "images/main/sub_icons/user_up_n.png"
    local higImg = "images/main/sub_icons/user_up_h.png"
    local item = CCMenuItemImage:create(norImg, higImg)
    item:setAnchorPoint(ccp(0.5, 0.5))
    item:registerScriptTapHandler(_itemArray[USER_UP].actionCallback)
    _itemArray[USER_UP].item = item
    local button = createButtonWithItem(item)
    return button
end

_itemArray[USER_UP].isShow = function ( ... )
    local isQuickReg = LoginScene.isQuickReg()
    if isQuickReg then
        return true
    else
        return false
    end
end
_itemArray[USER_UP].actionCallback = function ( ... )
    require "script/ui/userUp/UserUpLayer"
    UserUpLayer.showLayer(-1000, 1000)
end



--回归三国
_itemArray[PLAY_BACK] = {}
_itemArray[PLAY_BACK].createButton = function ( ... )
    local norImg = "images/main/sub_icons/play_back_n.png"
    local higImg = "images/main/sub_icons/play_back_h.png"
    local item = CCMenuItemImage:create(norImg, higImg)
    item:setAnchorPoint(ccp(0.5, 0.5))
    item:registerScriptTapHandler(_itemArray[PLAY_BACK].actionCallback)
    _itemArray[PLAY_BACK].item = item
    local button = createButtonWithItem(item)
     --小红点
    if item.tipSprite then
        item.tipSprite:removeFromParentAndCleanup(true)
        item.tipSprite = nil
    end
    require "script/ui/playerBack/PlayerBackData"
    local isShowTip = PlayerBackData.isRedTip()
    local tipSprite = CCSprite:create("images/common/tip_2.png")
    tipSprite:setAnchorPoint(ccp(0.5,0.5))
    tipSprite:setPosition(ccp(item:getContentSize().width*0.8,item:getContentSize().height*0.8))
    item:addChild(tipSprite,1,1915)
    tipSprite:setVisible(isShowTip)
    item.tipSprite = tipSprite
    return button
end

_itemArray[PLAY_BACK].isShow = function ( ... )
    require "script/ui/playerBack/PlayerBackData"
    local isShow = PlayerBackData.isOpen()
    return isShow
end
_itemArray[PLAY_BACK].actionCallback = function ( ... )
    -- 回归三国
    require "script/ui/playerBack/PlayerBackLayer"
    PlayerBackLayer.show()
end

--回归三国
_itemArray[REAL_NAME] = {}
_itemArray[REAL_NAME].createButton = function ( ... )
    local norImg = "images/main/sub_icons/real1.png"
    local higImg = "images/main/sub_icons/real2.png"
    local item = CCMenuItemImage:create(norImg, higImg)
    item:setAnchorPoint(ccp(0.5, 0.5))
    item:registerScriptTapHandler(_itemArray[REAL_NAME].actionCallback)
    _itemArray[PLAY_BACK].item = item
    local button = createButtonWithItem(item)
     --小红点
    if item.tipSprite then
        item.tipSprite:removeFromParentAndCleanup(true)
        item.tipSprite = nil
    end
    require "script/ui/playerBack/PlayerBackData"
    local isShowTip = PlayerBackData.isRedTip()
    local tipSprite = CCSprite:create("images/common/tip_2.png")
    tipSprite:setAnchorPoint(ccp(0.5,0.5))
    tipSprite:setPosition(ccp(item:getContentSize().width*0.8,item:getContentSize().height*0.8))
    item:addChild(tipSprite,1,1915)
    tipSprite:setVisible(isShowTip)
    item.tipSprite = tipSprite
    return button
end

_itemArray[REAL_NAME].isShow = function ( ... )
     --官网用户需要实名认证
    if Platform.getCurrentPlatform() == kPlatform_AppStore or Platform.isZYXSdk() then
        require "script/ui/realname/RealNameData"
        local id = RealNameData.getIdCardStatus()
        if(id and id==0 )then
            return true
        else
            return false
        end
    else
        return false
    end
end

_itemArray[REAL_NAME].actionCallback = function ( ... )
    -- 请求之后再判断是否弹框
    require "script/ui/login/LoginController"
    LoginController.getplatformuserinfo(function() 
        local realnamestatus = RealNameData.getRealNameStatus()
        if realnamestatus == 0 then
            require "script/ui/realname/RealNameInputLayer"
            RealNameInputLayer.showAlert()
        elseif realnamestatus == 1 then
            AnimationTip.showTip("已经完成实名认证")
        elseif realnamestatus == 2 then
            AnimationTip.showTip("实名认证状态异常，请联系客服")
        elseif  realnamestatus == 3 then
            AnimationTip.showTip("已提交实名认证信息，正在实名认证中")
        end
    end)
end


--在线奖励
_itemArray[ONLINE] = {}
_itemArray[ONLINE].createButton = function ( ... )
    local item = CCSprite:create()
    item:setContentSize(CCSizeMake(100, 100))
    require "script/ui/online/OnlineRewardBtn"
    require "script/ui/main/MainScene"
    OnlineRewardBtn.createOnlineRewardBtn(item)
    _itemArray[ONLINE].item = item
    return item
end

_itemArray[ONLINE].isShow = function ( ... )
    require "script/ui/online/OnlineRewardBtn"
    local isShow = OnlineRewardBtn.isShow()
    return isShow
end

--等级礼包
_itemArray[LEVE_REWARD] = {}
_itemArray[LEVE_REWARD].createButton = function ( ... )

    local item = CCSprite:create()
    item:setContentSize(CCSizeMake(100, 100))
    require "script/ui/level_reward/LevelRewardBtn"
    LevelRewardBtn.createLevelRewardBtn(item)
    _itemArray[LEVE_REWARD].item = item
    return item
end

_itemArray[LEVE_REWARD].isShow = function ( ... )
    require "script/ui/level_reward/LevelRewardBtn"
    local isShow = LevelRewardBtn.isShow()
    return isShow
end

--开服礼包
_itemArray[SERVER_GIFT] = {}
_itemArray[SERVER_GIFT].createButton = function ( ... )
    local item = CCSprite:create()
    item:setContentSize(CCSizeMake(100, 100))
    require "script/ui/sign/AccSignRewardLayer"
    AccSignRewardLayer.createAccSingBtn(item)
    _itemArray[SERVER_GIFT].item = item
    return item
end

_itemArray[SERVER_GIFT].isShow = function ( ... )
    require "script/ui/sign/AccSignRewardLayer"
    local isShow = AccSignRewardLayer.isShow()
    return isShow
end

--开服活动
_itemArray[OPEN_ACT] = {}
_itemArray[OPEN_ACT].createButton = function ( ... )
    local item= CCMenuItemImage:create("images/main/sub_icons/open_act_btn_n.png", "images/main/sub_icons/open_act_btn_h.png")
    item:registerScriptTapHandler(_itemArray[OPEN_ACT].actionCallback)
    item:setContentSize(CCSizeMake(100, 100))

    require "script/ui/newServerActivity/NewServerActivityData"
    local isShowTip = NewServerActivityData.isRedTip()
    showTipSprite(item, isShowTip)
    local button = createButtonWithItem(item)
    return button
end
_itemArray[OPEN_ACT].actionCallback = function ( ... )
    require "script/ui/newServerActivity/NewServerActivityLayer"
    NewServerActivityLayer.show()
end

_itemArray[OPEN_ACT].isShow = function ( ... )
    require "script/ui/newServerActivity/NewServerActivityData"
    local isShow = NewServerActivityData.isOpen()
    return isShow
end

--节日狂欢
_itemArray[CARNIVAL] = {}
_itemArray[CARNIVAL].createButton = function ( ... )
    local item= CCMenuItemImage:create("images/main/sub_icons/carnival_act_btn_n.png", "images/main/sub_icons/carnival_act_btn_n.png")
    -- local item= CCMenuItemImage:create("images/recharge/xshd_bnt_n.png", "images/recharge/xshd_btn_h.png")
    item:registerScriptTapHandler(_itemArray[CARNIVAL].actionCallback)
    item:setContentSize(CCSizeMake(100, 100))

    local newAnimSprite = XMLSprite:create("images/holidayhappy/effect/jierikuanghuan/jierikuanghuan")
    newAnimSprite:setPosition(ccp(item:getContentSize().width/2,item:getContentSize().height/2))
    newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    item:addChild(newAnimSprite,-1)
    local data = HolidayHappyData.getDataOfAll()
    if(table.isEmpty(data))then
        showTipSprite(item, false)
        local button = createButtonWithItem(item)
        return button
    else
        require "script/ui/holidayhappy/HolidayHappyData"
        local isShowTip = HolidayHappyData.isRedTipOfMainLayer()
        showTipSprite(item, isShowTip)
        local button = createButtonWithItem(item)
        return button
    end 
end
_itemArray[CARNIVAL].actionCallback = function ( ... )
    require "script/ui/holidayhappy/HolidayHappyLayer"
    HolidayHappyLayer.show()
end

_itemArray[CARNIVAL].isShow = function ( ... )
    require "script/ui/holidayhappy/HolidayHappyData"
    
    if(HolidayHappyData.isOpen() and not table.isEmpty(HolidayHappyData.getDataOfAll()))then
        return true
    else    

        return false
    end
end

--周年庆活动
_itemArray[ANNIVER] = {}
_itemArray[ANNIVER].createButton = function ( ... )
    local item = nil
    require "script/ui/anniver/AnniverData"
    -- 小红点添加 兑换商店
    if AnniverData.isOpen() then
        require "script/ui/anniver/AnniverUtil"
        local btnStr = AnniverUtil.getMainBtnStr()
        local imagPath = "images/anniver/"
        item= CCMenuItemImage:create(imagPath..btnStr.."_n.png", imagPath..btnStr.."_h.png")
        item:registerScriptTapHandler(_itemArray[ANNIVER].actionCallback)
        item:setContentSize(CCSizeMake(130, 100))
        local btnEfc = AnniverUtil.getMainBtnEfc()
        if btnEfc then
            local btnEfcStr = "images/anniver/effect/"..btnEfc.."/"..btnEfc
            local newAnimSprite = XMLSprite:create("images/anniver/effect/"..btnEfc.."/"..btnEfc)
            newAnimSprite:setPosition(ccp(item:getContentSize().width/2,item:getContentSize().height/2))
            item:addChild(newAnimSprite)
        end
        require "script/ui/anniver/AnniverData"
        local isShowTip = AnniverData.isRedTipInMainLayer()
        showTipSprite(item, isShowTip)
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[ANNIVER].actionCallback = function ()
    if AnniverData.isOpen() then
        require "script/ui/anniver/AnniverLayer"
        AnniverLayer.show()
    end
end
_itemArray[ANNIVER].isShow = function ()
    require "script/ui/anniver/AnniverData"
    require "script/ui/anniver/timelimitsign/TimelimitsignData"
    local isShowBtn = AnniverData.isOpen()
    return isShowBtn
end

--周年庆蛋糕活动
_itemArray[ANNIVER_CAKE] = {}
_itemArray[ANNIVER_CAKE].createButton = function ( ... )
    local item = nil
    require "script/ui/anniver/timelimitsign/TimelimitsignData"
    -- 小红点添加 兑换商店
    if TimelimitsignData.isOpen() then
        item= CCMenuItemImage:create("images/anniver/eatcake_n.png", "images/anniver/eatcake_h.png")
        item:registerScriptTapHandler(_itemArray[ANNIVER_CAKE].actionCallback)
        item:setContentSize(CCSizeMake(100, 90))
        
        local isShowTip = TimelimitsignData.isShowRedTip()
        showTipSprite(item, isShowTip)
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[ANNIVER_CAKE].actionCallback = function ()
    if TimelimitsignData.isOpen() then
        require "script/ui/anniver/timelimitsign/TimelimitsignLayer"
        TimelimitsignLayer.showLayer()
    end
end
_itemArray[ANNIVER_CAKE].isShow = function ()
    require "script/ui/anniver/timelimitsign/TimelimitsignData"
    local isShowBtn = TimelimitsignData.isOpen()
    return isShowBtn
end

--周年抽奖
_itemArray[ANNIV_LOTTERY] = {}
_itemArray[ANNIV_LOTTERY].createButton = function ( ... )
    require "script/ui/anniver/lottery/LotteryData"
    local item = nil
    if LotteryData.isOpen() then
         -- 小红点添加 兑换商店
        require "script/ui/anniver/lottery/LotteryData"
        local btnStr = LotteryData.getMainIcon()
        local imagPath = "images/anniver/lottery/"
        item= CCMenuItemImage:create(imagPath..btnStr.."_n.png", imagPath..btnStr.."_h.png")
        item:registerScriptTapHandler(_itemArray[ANNIV_LOTTERY].actionCallback)
        item:setContentSize(CCSizeMake(117, 96))
        local btnEfc = LotteryData.getMainEfc()
        if btnEfc then
            local newAnimSprite = XMLSprite:create("images/anniver/lottery/effect/"..btnEfc.."/"..btnEfc)
            newAnimSprite:setPosition(ccp(item:getContentSize().width/2,item:getContentSize().height/2))
            item:addChild(newAnimSprite)
        end
        local isShowTip = LotteryData.isShowRedTip()
        showTipSprite(item, isShowTip)
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[ANNIV_LOTTERY].actionCallback = function ( ... )
    require "script/ui/anniver/lottery/LotteryLayer"
    LotteryLayer.show()
end
_itemArray[ANNIV_LOTTERY].isShow = function ( ... )
    require "script/ui/anniver/lottery/LotteryData"
    return LotteryData.isOpen()
end

--迎财神
_itemArray[RICH_GOD] = {}
_itemArray[RICH_GOD].createButton = function ( ... )
    require "script/ui/rechargeActive/richGod/RichGodData"
    local item = nil
   
    if RichGodData.isOpen() then   
         -- 小红点添加 
        item= CCMenuItemImage:create("images/recharge/rich_god_n.png", "images/recharge/rich_god_h.png")
        item:registerScriptTapHandler(_itemArray[RICH_GOD].actionCallback)
        item:setContentSize(CCSizeMake(130, 100))

        local isShowTip = RichGodData.isShowRedTip()
        showTipSprite(item, isShowTip)
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[RICH_GOD].actionCallback = function ( ... )
    print("RICH_GOD].actionCallback")
    require "script/ui/rechargeActive/richGod/RichGodLayer"
    RichGodLayer.showLayer()
end
_itemArray[RICH_GOD].isShow = function ( ... )
    require "script/ui/rechargeActive/richGod/RichGodData"
    return RichGodData.isOpen()
end

--世界杯
_itemArray[WORLD_CUP] = {}
_itemArray[WORLD_CUP].createButton = function ( ... )
    require "script/ui/worldcup/WorldCupData"
    local item = nil

    if WorldCupData.isOpen() then   
         -- 小红点添加
        local normalSprite  = CCSprite:create()
        normalSprite:setContentSize(CCSizeMake(136,105))
        local selectSprite  = CCSprite:create()
        selectSprite:setContentSize(CCSizeMake(136,105))
        item = CCMenuItemSprite:create(normalSprite,selectSprite) 
        local effect = XMLSprite:create("images/recharge/worldcap/effect/shijiebeiTX_anniu/shijiebeiTX_anniu")
        effect:setPosition(ccpsprite(0.5, 0.5, item))
        item:addChild(effect)
        --effectSprite:setPosition(ccp(bgWidget:getContentSize().width*0.5+10,bgWidget:getContentSize().height*0.5))
        item:registerScriptTapHandler(_itemArray[WORLD_CUP].actionCallback)


        local isShowTip = WorldCupData.isShowRedTipMainView()
        showTipSprite(item, isShowTip)
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[WORLD_CUP].actionCallback = function ( ... )
    require "script/ui/worldcup/WorldCupController"
    WorldCupController.getInfo()
end
_itemArray[WORLD_CUP].isShow = function ( ... )
    require "script/ui/worldcup/WorldCupData"
    return WorldCupData.isOpen()
end

--6周年活动
_itemArray[ANNIV_SIXTH] = {}
_itemArray[ANNIV_SIXTH].createButton = function ( ... )
    require "script/ui/annivsixth/AnnivSixthData"
    local item = nil

    if AnnivSixthData.isOpen() then   
        -- 按钮
        local iconCfg = AnnivSixthData.getEnterIcon()
        item= CCMenuItemImage:create(iconCfg[1], iconCfg[2])
        item:registerScriptTapHandler(_itemArray[ANNIV_SIXTH].actionCallback)
        item:setContentSize(CCSizeMake(130, 100))

        -- 小红点添加
        local isShowTip = AnnivSixthData.isShowRedTip()
        showTipSprite(item, isShowTip)
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[ANNIV_SIXTH].actionCallback = function ( ... )
    require "script/ui/annivsixth/AnnivSixthController"
    AnnivSixthController.showLayer()
end
_itemArray[ANNIV_SIXTH].isShow = function ( ... )
    require "script/ui/annivsixth/AnnivSixthData"
    return AnnivSixthData.isOpen()
end

--8周年活动
_itemArray[ANNIV_EIGHTH] = {}
_itemArray[ANNIV_EIGHTH].createButton = function ( ... )
    require "script/ui/annivEighth/AnnivEighthData"
    local item = nil

    if ActivityConfigUtil.isActivityOpen("annivEighth") then
        -- 按钮
        item= CCMenuItemImage:create("images/main/sub_icons/drum_n.png", "images/main/sub_icons/drum_h.png")
        item:registerScriptTapHandler(_itemArray[ANNIV_EIGHTH].actionCallback)
        item:setContentSize(CCSizeMake(130, 100))

        -- 小红点添加
        local isShowTip = AnnivEighthData.isShowRedTip()
        showTipSprite(item, isShowTip)
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[ANNIV_EIGHTH].actionCallback = function ( ... )
    require "script/ui/annivEighth/AnnivEighthMainLayer"
    AnnivEighthMainLayer.showLayer()
end
_itemArray[ANNIV_EIGHTH].isShow = function ( ... )
    return ActivityConfigUtil.isActivityOpen("annivEighth")
end

--9周年活动
_itemArray[ANNIV_NINETH] = {}
_itemArray[ANNIV_NINETH].createButton = function ( ... )
    require "script/ui/annivNineth/AnnivNinethData"
    local item = nil

    if ActivityConfigUtil.isActivityOpen("annivNinth") then
        -- 按钮
        item= CCMenuItemImage:create("images/recharge/9Anniversary/title_n.png", "images/recharge/9Anniversary/title_h.png")
        item:registerScriptTapHandler(_itemArray[ANNIV_NINETH].actionCallback)
        item:setContentSize(CCSizeMake(120, 105))
        -- local normalSprite  = CCSprite:create()
        -- normalSprite:setContentSize(CCSizeMake(136,105))
        -- local selectSprite  = CCSprite:create()
        -- selectSprite:setContentSize(CCSizeMake(136,105))
        -- item = CCMenuItemSprite:create(normalSprite,selectSprite) 
        -- local effect = XMLSprite:create("images/recharge/9Anniversary/jiujiuxiangbanTX/jiujiuxiangbanTX")
        -- effect:setPosition(ccpsprite(0.5, 0.5, item))
        -- item:addChild(effect)
        --effectSprite:setPosition(ccp(bgWidget:getContentSize().width*0.5+10,bgWidget:getContentSize().height*0.5))
        -- item:registerScriptTapHandler(_itemArray[ANNIV_NINETH].actionCallback)

        -- 小红点添加
        -- local isShowTip = AnnivEighthData.isShowRedTip()
        -- showTipSprite(item, isShowTip)
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[ANNIV_NINETH].actionCallback = function ( ... )
    require "script/ui/annivNineth/AnnivNinethLayer"
    AnnivNinethLayer.showLayer()
end
_itemArray[ANNIV_NINETH].isShow = function ( ... )
    return ActivityConfigUtil.isActivityOpen("annivNinth")
end

--9周年活动
_itemArray[ANNIV_TEN] = {}
_itemArray[ANNIV_TEN].createButton = function ( ... )
    local item = nil
    if ActivityConfigUtil.isActivityOpen("annivTenthPuzzle") then
        -- 按钮
        local normalSprite  = CCSprite:create()
        normalSprite:setContentSize(CCSizeMake(136,105))
        local selectSprite  = CCSprite:create()
        selectSprite:setContentSize(CCSizeMake(136,105))
        item = CCMenuItemSprite:create(normalSprite,selectSprite) 
        local effect = XMLSprite:create("images/act_ten_years/10years_rukou/10years_rukou")
        effect:setPosition(ccpsprite(0.5, 0.5, item))
        item:addChild(effect)
        item:registerScriptTapHandler(_itemArray[ANNIV_TEN].actionCallback)
        require "script/ui/annivten/AnnivTenData"
        -- 小红点添加
        local isShowTip = AnnivTenData.isShowRedTip()
        showTipSprite(item, isShowTip)
        -- item:setContentSize(CCSizeMake(130, 100))
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[ANNIV_TEN].actionCallback = function ( ... )
    require "script/ui/annivten/AnnivTenData"
    local isOver = AnnivTenData.isActOver()
    if isOver then 
        AnimationTip.showTip("活动已结束")
        return
    end
    require "script/ui/annivten/AnnivTenMainLayer"
    AnnivTenMainLayer.showLayer()
end
_itemArray[ANNIV_TEN].isShow = function ( ... )
    return ActivityConfigUtil.isActivityOpen("annivTenthPuzzle")
end

--11周年活动
_itemArray[ANNIV_ELEVEN] = {} 
_itemArray[ANNIV_ELEVEN].createButton = function ( ... )
    local item = nil
    if ActivityConfigUtil.isActivityOpen("annivElevenSign") then
        -- 按钮
        item = CCMenuItemImage:create("images/main/sub_icons/11th_n.png", "images/main/sub_icons/11th_h.png")
        item:registerScriptTapHandler(_itemArray[ANNIV_ELEVEN].actionCallback)
        -- 小红点添加
        require "script/ui/annivEleven/AnnivElevenData"
        local isShowTip = AnnivElevenData.isShowRedTip()
        showTipSprite(item, isShowTip)
        item:setContentSize(CCSizeMake(130, 100))
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[ANNIV_ELEVEN].actionCallback = function ( ... )
    require "script/ui/annivEleven/AnnivElevenMainLayer"
    AnnivElevenMainLayer.showLayer()
end
_itemArray[ANNIV_ELEVEN].isShow = function ( ... )
    require "script/ui/annivEleven/AnnivElevenData"
    return AnnivElevenData.isOpen()
end

--直购类活动
_itemArray[DIRECT_ACT] = {} 
_itemArray[DIRECT_ACT].createButton = function ( ... )
    local item = nil
    require "script/ui/directActs/DirectActMainData"
    local isOpen = DirectActMainData.isOpen()
    if isOpen then
        -- 按钮
        item = CCMenuItemImage:create("images/main/sub_icons/act_direct_n.png", "images/main/sub_icons/act_direct_h.png")
        item:registerScriptTapHandler(_itemArray[DIRECT_ACT].actionCallback)
        -- 小红点添加
        require "script/ui/rechargeActive/directWarOrder/DirectWarOrderData"
        local isShowTip = DirectActMainData.isRedTip()
        showTipSprite(item, isShowTip)
        item:setContentSize(CCSizeMake(130, 100))
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[DIRECT_ACT].actionCallback = function ( ... )
    require "script/ui/directActs/DirectActMainLayer"
    DirectActMainLayer.showLayer()
end
_itemArray[DIRECT_ACT].isShow = function ( ... )
    require "script/ui/directActs/DirectActMainData"
    return DirectActMainData.isOpen()
end

--幸运锦鲤活动
_itemArray[LUCKY_FISH] = {}
_itemArray[LUCKY_FISH].createButton = function ( ... )
    local item = nil
    if ActivityConfigUtil.isActivityOpen("luckyDoi") then
        -- 按钮
        item = CCMenuItemImage:create("images/main/sub_icons/my_fish_n.png", "images/main/sub_icons/my_fish_h.png")
        item:registerScriptTapHandler(_itemArray[LUCKY_FISH].actionCallback)
        -- 小红点添加
        require "script/ui/luckyFish/LuckyFishData"
        local isShowTip = LuckyFishData.isShowRedTip()
        showTipSprite(item, isShowTip)
        item:setContentSize(CCSizeMake(130, 100))
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[LUCKY_FISH].actionCallback = function ( ... )
    require "script/ui/luckyFish/LuckyFishMainLayer"
    LuckyFishMainLayer.showLayer()
end
_itemArray[LUCKY_FISH].isShow = function ( ... )
    require "script/ui/luckyFish/LuckyFishData"
    return LuckyFishData.isOpen()
end

-- --限时礼包20240415
-- _itemArray[TIME_BAG] = {}
-- _itemArray[TIME_BAG].createButton = function ( ... )
--     local item = nil
--     if UserModel.getHeroLevel() >= 10 then
--         -- 按钮
--         item = CCMenuItemImage:create("images/main/sub_icons/limitgift_n.png", "images/main/sub_icons/limitgift_h.png")
--         item:registerScriptTapHandler(_itemArray[TIME_BAG].actionCallback)
--         -- 小红点添加
--         require "script/ui/timebag/TimeBagData"
--         local isShowTip = TimeBagData.ishowRedTip()
--         showTipSprite(item, isShowTip)
--         item:setContentSize(CCSizeMake(130, 100))
--         item = createButtonWithItem(item)
--     else
--         item = CCSprite:create()
--         item:setContentSize(CCSizeMake(100, 100))
--     end
--     return item
-- end
-- _itemArray[TIME_BAG].actionCallback = function ( ... )
--     require "script/ui/timebag/TimeBagLayer"
--     TimeBagLayer.showLayer()
-- end
-- _itemArray[TIME_BAG].isShow = function ( ... )
--     require "script/ui/timebag/TimeBagData"
--     return TimeBagData.isShowBtn()
-- end


--运营活动
_itemArray[YUN_YING] = {}
_itemArray[YUN_YING].createButton = function ( ... )
    local item = nil
    local isOpen = true
    if isOpen then
        -- 按钮
        item= CCMenuItemImage:create("images/main/sub_icons/surprise_n.png", "images/main/sub_icons/surprise_h.png")
        item:registerScriptTapHandler(_itemArray[YUN_YING].actionCallback)
        item:setContentSize(CCSizeMake(130, 100))
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[YUN_YING].actionCallback = function ( ... )
    require "script/ui/yunyinghuodong/YunYingHuoDongLayer"
    YunYingHuoDongLayer.showLayer(-888,1888)
end
_itemArray[YUN_YING].isShow = function ( ... )
--正式url和活动按钮没有暂不显示
-- 华为的关闭此功能 荣耀
    if Platform.getPlName() == "hwphone" or Platform.getPlatformUrlName() == "Android_honor" or Platform.getPlatformUrlName() == "Android_xm" then
        return false
    else
        return true
    end
end

--美人画卷
_itemArray[BEAUTY] = {}
_itemArray[BEAUTY].createButton = function ( ... )
    require "script/ui/beauty/BeautyData"
    local item = nil
    if BeautyData.isOpen() then   
        -- 按钮
        item= CCMenuItemImage:create("images/main/sub_icons/mrhj_n.png", "images/main/sub_icons/mrhj_h.png")
        item:registerScriptTapHandler(_itemArray[BEAUTY].actionCallback)
        -- 小红点添加
        local isShowTip = BeautyData.isShowRedTip()
        showTipSprite(item, isShowTip)
        item:setContentSize(CCSizeMake(130, 100))
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[BEAUTY].actionCallback = function ( ... )
    require "script/ui/beauty/BeautyMainLayer"
    BeautyMainLayer.showLayer()
end
_itemArray[BEAUTY].isShow = function ( ... )
    return BeautyData.isOpen()
end


--回归有礼商店
_itemArray[REGRESS] = {}
_itemArray[REGRESS].createButton = function ( ... )
    require "script/ui/regress/RegressData"
    local item = nil

    if RegressData.isOpen() then
        -- 按钮
        item= CCMenuItemImage:create("images/main/sub_icons/return_shop_n.png", "images/main/sub_icons/return_shop_h.png")
        item:registerScriptTapHandler(_itemArray[REGRESS].actionCallback)
        item:setContentSize(CCSizeMake(130, 100))

        -- 小红点添加
        local isShowTip = RegressData.isShowRedTip()
        showTipSprite(item, isShowTip)
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[REGRESS].actionCallback = function ( ... )
    require "script/ui/regress/RegressMainLayer"
    RegressMainLayer.showLayer(-400,1000)
end
_itemArray[REGRESS].isShow = function ( ... )
    return RegressData.isOpen()
end

--战令系统
_itemArray[WARORDER] = {}
_itemArray[WARORDER].createButton = function ( ... )
    require "script/ui/warorder/WarorderData"
    local item = nil

    if WarorderData.isOpen() then
    -- if true then
        -- 按钮
        item= CCMenuItemImage:create("images/battlecard/battlecard_n.png", "images/battlecard/battlecard_h.png")
        item:registerScriptTapHandler(_itemArray[WARORDER].actionCallback)
        -- 小红点添加
        local isShowTip = WarorderData.isShowRedTip()
        showTipSprite(item, isShowTip)
        item:setContentSize(CCSizeMake(130, 100))
        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[WARORDER].actionCallback = function ( ... )
    require "script/ui/warorder/WarorderController"
    WarorderController.showLayer()
end
_itemArray[WARORDER].isShow = function ( ... )
     require "script/ui/warorder/WarorderData"
    return WarorderData.isOpen()
end

--问卷调查
_itemArray[QUESTIONNAIRE] = {}
_itemArray[QUESTIONNAIRE].createButton = function ( ... )
    require "script/ui/questionnaire/QuestionnaireData"
    local item = nil
    if QuestionnaireData.isOpen() then   
        -- 按钮
        item= CCMenuItemImage:create("images/main/sub_icons/question_n.png", "images/main/sub_icons/question_h.png")
        item:registerScriptTapHandler(_itemArray[QUESTIONNAIRE].actionCallback)
        item:setContentSize(CCSizeMake(130, 100))

        item = createButtonWithItem(item)
    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[QUESTIONNAIRE].actionCallback = function ( ... )
    require "script/ui/questionnaire/QuestionnaireMainLayer"
    QuestionnaireMainLayer.show()
end
_itemArray[QUESTIONNAIRE].isShow = function ( ... )
    require "script/ui/questionnaire/QuestionnaireData"
    return QuestionnaireData.isOpen()
end

--新服排行
_itemArray[SERVER_RANK] = {}
_itemArray[SERVER_RANK].createButton = function ( ... )
    require "script/ui/server_rank/ServerRankData"
    local item = nil
    if ServerRankData.isOpen() then   
        -- 按钮
        item= CCMenuItemImage:create("images/main/sub_icons/zhanli_reward_n.png", "images/main/sub_icons/zhanli_reward_n.png")
        item:registerScriptTapHandler(_itemArray[SERVER_RANK].actionCallback)
        item:setContentSize(CCSizeMake(100, 100))

        item = createButtonWithItem(item)

        local xmlSprite = XMLSprite:create("images/zhanli_reward/zhanlipaihangTX/zhanlipaihangTX");
        xmlSprite:setPosition(ccp(item:getContentSize().width*0.5,item:getContentSize().height/2))
        -- xmlSprite:setAnchorPoint(ccp(0.5,0.5))
        item:addChild(xmlSprite)

    else
        item = CCSprite:create()
        item:setContentSize(CCSizeMake(100, 100))
    end
    return item
end
_itemArray[SERVER_RANK].actionCallback = function ( ... )
    require "script/ui/server_rank/ServerRankData"
    if not ServerRankData.isOpen() then
        AnimationTip.showTip(GetLocalizeStringBy("key_2447"))
        return
    end
    require "script/ui/server_rank/ServerRankMainLayer"
    ServerRankMainLayer.showLayer()
end
_itemArray[SERVER_RANK].isShow = function ( ... )
    require "script/ui/server_rank/ServerRankData"
    return ServerRankData.isOpen()
end

--奖励中心
_itemArray[REWARD_CENTER] = {}
_itemArray[REWARD_CENTER].createButton = function ( ... )

    local btnSprite = CCScale9Sprite:create("images/common/transparent.png", CCRectMake(0, 0, 3, 3), CCRectMake(1, 1, 1, 1))
    btnSprite:setPreferredSize(CCSizeMake(100, 100))
    local rewardCenterBtn = CCMenuItemSprite:create(btnSprite, btnSprite)
    rewardCenterBtn:setPosition(0, 0)
    rewardCenterBtn:setAnchorPoint(ccp(0, 0))
    rewardCenterBtn:registerScriptTapHandler(_itemArray[REWARD_CENTER].actionCallback)

    local menu = CCMenu:create()
    menu:setPosition(0, 0)
    menu:setAnchorPoint(ccp(0, 0))
    menu:addChild(rewardCenterBtn)

    local _itemSprite = CCSprite:create()
    _itemSprite:setContentSize(CCSizeMake(100, 100))
    _itemSprite:setAnchorPoint(ccp(0.5, 0.5))
    _itemSprite:addChild(menu)

    local imgPath = "images/base/effect/baoxiang/baoxiang"
    local effect = XMLSprite:create(imgPath)
    effect:setPosition(ccpsprite(0.5, 0.23, _itemSprite))
    _itemSprite:addChild(effect)

    _itemArray[REWARD_CENTER].item = _itemSprite
    return _itemSprite
end
_itemArray[REWARD_CENTER].actionCallback = function ( ... )
    require "script/ui/rewardCenter/RewardCenterView"
    AudioUtil.playEffect("audio/effect/zhujiemian.mp3")
    local runScene = CCDirector:sharedDirector():getRunningScene()
    local rewardLayer  = RewardCenterView.create()
    runScene:addChild(rewardLayer,1500)
end
_itemArray[REWARD_CENTER].isShow = function ( ... )
    if DataCache.getRewardCenterStatus() then
        return true
    end
    return false
end

--跨服战
_itemArray[WORLD] = {}
_itemArray[WORLD].createButton = function ( ... )
    require "script/ui/main/WorldButtonUtil"
    local button = WorldButtonUtil.createButton()
    _itemArray[WORLD].zOrder = 99999
    return button
end
_itemArray[WORLD].isShow = function ( ... )
    require "script/ui/main/WorldButtonUtil"
    local isShow = WorldButtonUtil.isShow()
    return isShow
end

--资源回收
_itemArray[RES_RECOVER] = {}
_itemArray[RES_RECOVER].createButton = function ( ... )
    require "script/model/DataCache"
    local item= CCMenuItemImage:create("images/retrieve/retrieve_n.png", "images/retrieve/retrieve_h.png")
    item:registerScriptTapHandler(_itemArray[RES_RECOVER].actionCallback)
    require "script/ui/recover/ReResourceData"
    local isFirst = ReResourceData.getIsFirst()
    if(isFirst)then
        item:setVisible(false)
    else
        item:setVisible(true)
    end
    local newAnimSprite = XMLSprite:create("images/base/effect/yao/yao");
    newAnimSprite:setPosition(ccp(item:getContentSize().width*0.5,item:getContentSize().height/2+5))
    newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    item:addChild(newAnimSprite,-1)
    local button = createButtonWithItem(item)
    return button
end
_itemArray[RES_RECOVER].actionCallback = function ( ... )
    AudioUtil.playEffect("audio/effect/zhujiemian.mp3")
    require "script/ui/recover/ReResourceLayer"
    local isHaveRetrive = ReResourceData.ifHaveReward()
    if(isHaveRetrive)then
        local runScene = CCDirector:sharedDirector():getRunningScene()
        local rewardLayer  = ReResourceLayer.create()
        runScene:addChild(rewardLayer,1500)
    end
end
_itemArray[RES_RECOVER].isShow = function ( ... )
    require "script/model/DataCache"
    local isShow = DataCache.getReResourceStatus()
    return isShow
end
--逐鹿中原
_itemArray[COMPETE] = {}
_itemArray[COMPETE].createButton = function ( ... )
    -- require "script/model/DataCache"
    local item= CCMenuItemImage:create("images/compete/detail/main_h.png", "images/compete/detail/main_n.png")
    item:registerScriptTapHandler(_itemArray[COMPETE].actionCallback)
    local newAnimSprite = XMLSprite:create("images/base/effect/yao/yao");
    newAnimSprite:setPosition(ccp(item:getContentSize().width*0.5,item:getContentSize().height/2))
    newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    item:addChild(newAnimSprite,-1)
    local button = createButtonWithItem(item)
    return button
end
_itemArray[COMPETE].actionCallback = function ( ... )
    AudioUtil.playEffect("audio/effect/zhujiemian.mp3")
    local conFirmCb= function ( p_flag )
        if(not p_flag)then
            return
        end
        require "script/ui/compete/CompeteMainMapLayer"
        CompeteMainMapLayer.createLayer()
    end
    require "script/ui/compete/CompeteMainAlert"
    CompeteMainAlert.showAlert(GetLocalizeStringBy("djn_389"), conFirmCb, true, nil, GetLocalizeStringBy("key_1985"),GetLocalizeStringBy("key_1202"),nil,nil,nil,true)

    
end
_itemArray[COMPETE].isShow = function ( ... )
    require "script/ui/compete/CompeteData"     
    local isShow =  CompeteData.isTipInMain()
    return isShow
end

--资源矿空旷
_itemArray[RES_EMPTY] = {}
_itemArray[RES_EMPTY].createButton = function ( ... )
    require "script/model/DataCache"
    local item= CCMenuItemImage:create("images/main/res_tip_btn_n.png", "images/main/res_tip_btn_h.png")
    item:registerScriptTapHandler(_itemArray[RES_EMPTY].actionCallback)
    local button = createButtonWithItem(item)
    return button
end
_itemArray[RES_EMPTY].actionCallback = function ( ... )
    AudioUtil.playEffect("audio/effect/zhujiemian.mp3")
    AlertTip.showAlert(GetLocalizeStringBy("lcyx_3026"),function ( isConfirm )
        if isConfirm then
            require "script/ui/active/mineral/MineralLayer"
            local mineralLayer = MineralLayer.createLayer()
            MainScene.changeLayer(mineralLayer, "mineralLayer")
        end
    end, true)
end
_itemArray[RES_EMPTY].isShow = function ( ... )
    require "script/ui/active/mineral/MineralData"
    local isShow = MineralData.getNormalPitEmpyt()
    print("RES_EMPTY", isShow)
    return isShow
end
--跨服资源矿空旷
_itemArray[CROSS_RES_EMPTY] = {}
_itemArray[CROSS_RES_EMPTY].createButton = function ( ... )
    require "script/model/DataCache"
    local item= CCMenuItemImage:create("images/main/main_cromin_n.png", "images/main/main_cromin_h.png")
    item:registerScriptTapHandler(_itemArray[CROSS_RES_EMPTY].actionCallback)
    local button = createButtonWithItem(item)
    return button
end
_itemArray[CROSS_RES_EMPTY].actionCallback = function ( ... )
    AudioUtil.playEffect("audio/effect/zhujiemian.mp3")
    AlertTip.showAlert(GetLocalizeStringBy("yyl_47"),function ( isConfirm )
        if isConfirm then
            require "script/ui/acrossmineral/mineral/CrossMineralController"
            CrossMineralController.getActInfo(function()
                require "script/ui/acrossmineral/mineral/CrossMineralData"
                local actData = CrossMineralData.getActData()
                print("actData")
                print_t(actData)
                if actData.ret == "ok" then
                    require "script/ui/acrossmineral/mineral/CrossMineralLayer"
                    local crossMineralLayer = CrossMineralLayer.createLayer()
                    MainScene.changeLayer(crossMineralLayer, "crossmineralLayer")
                else
                    AnimationTip.showTip(GetLocalizeStringBy("yyl_33"))
                end
            end)
        end
    end, true)
end
_itemArray[CROSS_RES_EMPTY].isShow = function ( ... )
    require "script/ui/acrossmineral/mineral/CrossMineralData"
    local isShow = CrossMineralData.isShowMainSenceBtn()
    print("CROSS_RES_EMPTY", isShow)
    return isShow
end

--跨服擂台赛
_itemArray[KFLT_EMPTY_POS] = {}
_itemArray[KFLT_EMPTY_POS].createButton = function ( ... )
    require "script/model/DataCache"
    local item= CCMenuItemImage:create("images/main/main_kflt_n.png", "images/main/main_kflt_h.png")
    item:registerScriptTapHandler(_itemArray[KFLT_EMPTY_POS].actionCallback)
    local button = createButtonWithItem(item)
    return button
end
_itemArray[KFLT_EMPTY_POS].actionCallback = function ( ... )
    AudioUtil.playEffect("audio/effect/zhujiemian.mp3")
    local alertStr = "主公，您现在还未报名跨服擂台赛，是否前往报名？"
    local isIn = KFLeiTaiData.isInSignTime()
    if not isIn then
        alertStr = "主公，您现在尚未占领参赛席位，是否前往跨服擂台赛占领？"
    end
    AlertTip.showAlert(alertStr,function ( isConfirm )
        if isConfirm then
            local needLv = KFLeiTaiData.getNeedLv()
            local userLv = UserModel.getHeroLevel()
            if (userLv < needLv) then
                -- 玩家等级不够
                AnimationTip.showTip(GetLocalizeStringBy("key_1155")..needLv)
                return
            end
            require "script/ui/kflt/KFLeiTaiController"
            KFLeiTaiController.show()
        end
    end, true)
end
_itemArray[KFLT_EMPTY_POS].isShow = function ( ... )
    require "script/ui/kflt/KFLeiTaiData"
    local isShow = KFLeiTaiData.isShowMainSenceBtn()
    print("KFLT_EMPTY_POS", isShow)
    return isShow
end

--美人游历
_itemArray[HERO_BEAUTY] = {}
_itemArray[HERO_BEAUTY].createButton = function ( ... )
    require "script/model/DataCache"
    local item= CCMenuItemImage:create("images/main/hero_beauty_n.png", "images/main/hero_beauty_h.png")
    item:registerScriptTapHandler(_itemArray[HERO_BEAUTY].actionCallback)
    local button = createButtonWithItem(item)
    return button
end
_itemArray[HERO_BEAUTY].actionCallback = function ( ... )
    require "script/ui/heroBeauty/travel/HeroBeautyAlertDialog"
    HeroBeautyAlertDialog.showLayer(-9999,1212)
end
_itemArray[HERO_BEAUTY].isShow = function ( ... )
    require "script/ui/heroBeauty/travel/HeroBeautyTraData"
    local isShow = HeroBeautyTraData.isShowRedTip()
    print("HERO_BEAUTY", isShow)
    return isShow
end

--跨服排位赛可匹配阶段快速入口
_itemArray[BATTLE_RANK_FIGHT] = {}
_itemArray[BATTLE_RANK_FIGHT].createButton = function ()
    local item= CCMenuItemImage:create("images/main/main_battlerank_n.png", "images/main/main_battlerank_h.png")
    item:registerScriptTapHandler(_itemArray[BATTLE_RANK_FIGHT].actionCallback)
    local button = createButtonWithItem(item)
    return button
end
_itemArray[BATTLE_RANK_FIGHT].actionCallback = function ()
    require "script/ui/battlerank/main/BattleRankMainLayer"
    BattleRankMainLayer.showLayer(-400,1000)
end

_itemArray[BATTLE_RANK_FIGHT].isShow = function ()
    require "script/ui/battlerank/main/BattleRankMainData"
    local isCanBattle = BattleRankMainData.isCanBattle()
    local canBattle = BattleRankMainData.isInChallengeTime()
    return (isCanBattle and canBattle)
end

--跨服排位赛可匹配阶段快速入口
_itemArray[ANNIVER_FIFTH] = {}
_itemArray[ANNIVER_FIFTH].createButton = function ()
    local item= CCMenuItemImage:create("images/main/sub_icons/rongyao5_n.png", "images/main/sub_icons/rongyao5_h.png")
    item:registerScriptTapHandler(_itemArray[ANNIVER_FIFTH].actionCallback)
    local button = createButtonWithItem(item)

    -- local newAnimSprite = XMLSprite:create("images/recharge/Anniversary/effect/wuzhouniananniuTX/wuzhouniananniuTX")
    -- newAnimSprite:setPosition(ccpsprite(0.53, 0.51, item))
    -- newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    -- item:addChild(newAnimSprite,1)

    local alertSprite = CCSprite:create("images/common/tip_2.png")
    alertSprite:setAnchorPoint(ccp(0.5,0.5))
    alertSprite:setPosition(ccp(item:getContentSize().width*0.8,item:getContentSize().height*0.8))
    item:addChild(alertSprite,1,1998)
    require "script/ui/annivfifth/AnnivFifthData"
    local isShowTip = AnnivFifthData.isShowRedTip()
    alertSprite:setVisible(isShowTip)
    return button
end
_itemArray[ANNIVER_FIFTH].actionCallback = function ()
    require "script/ui/annivfifth/AnnivFifthLayer"
    AnnivFifthLayer.showLayer(-400,1000)
end

_itemArray[ANNIVER_FIFTH].isShow = function ()
    require "script/ui/annivfifth/AnnivFifthData"
    local isOpen = AnnivFifthData.isOpen()
    return isOpen
end


_itemArray[ANNIVER_SEVENTH] = {}
_itemArray[ANNIVER_SEVENTH].createButton = function ()
    local item1 = "images/main/sub_icons/brand_n.png"
    local item2 = "images/main/sub_icons/brand_h.png"
    require "script/ui/rechargeActive/sevenYear/SevenYearData"
    local confData = SevenYearData.getRewardConf()
    -- Logger.debug("zhu_Btn=======:%s", confData.data[1].zhu_Btn or "nil")
    if confData.data and confData.data[1] and confData.data[1].zhu_Btn then
        item1 = "images/main/sub_icons/" .. confData.data[1].zhu_Btn .. "_n.png"
        item2 = "images/main/sub_icons/" .. confData.data[1].zhu_Btn  .. "_h.png"
    end
    local item= CCMenuItemImage:create(item1, item2)
    item:registerScriptTapHandler(_itemArray[ANNIVER_SEVENTH].actionCallback)
    local button = createButtonWithItem(item)

    -- local newAnimSprite = XMLSprite:create("images/recharge/Anniversary/effect/wuzhouniananniuTX/wuzhouniananniuTX")
    -- newAnimSprite:setPosition(ccpsprite(0.53, 0.51, item))
    -- newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    -- item:addChild(newAnimSprite,1)

    local alertSprite = CCSprite:create("images/common/tip_2.png")
    alertSprite:setAnchorPoint(ccp(0.5,0.5))
    alertSprite:setPosition(ccp(item:getContentSize().width*0.8,item:getContentSize().height*0.8))
    item:addChild(alertSprite,1,1998)
    require "script/ui/rechargeActive/sevenYear/SevenYearData"
    local isShowTip = SevenYearData.isRedTip()
    alertSprite:setVisible(isShowTip)
    return button
end
_itemArray[ANNIVER_SEVENTH].actionCallback = function ()
    require "script/ui/rechargeActive/sevenYear/SevenYearLayer"
    SevenYearLayer.showLayer(-400,1000)
end

_itemArray[ANNIVER_SEVENTH].isShow = function ()
    require "script/ui/rechargeActive/sevenYear/SevenYearData"
    local isOpen = SevenYearData.isOpen()
    return isOpen
end


--跨服组队战邀请
_itemArray[WORLD_TEAM_INVITE] = {}
_itemArray[WORLD_TEAM_INVITE].createButton = function ()
    local item= CCMenuItemImage:create("images/kuafu_team/jdtip_icon_n.png", "images/kuafu_team/jdtip_icon_h.png")
    item:registerScriptTapHandler(_itemArray[WORLD_TEAM_INVITE].actionCallback)
    local button = createButtonWithItem(item)
    return button
end
_itemArray[WORLD_TEAM_INVITE].actionCallback = function ()
    require "script/ui/WorldTeam/invite/WorldTeamInvitionListLayer"
    WorldTeamInvitionListLayer.showLayer()
end

_itemArray[WORLD_TEAM_INVITE].isShow = function ()
    require "script/ui/WorldTeam/invite/WorldTeamInviteData"
    return WorldTeamInviteData.haveNewInvite()
end

--军团邀请
_itemArray[GUILD_INVITE] = {}
_itemArray[GUILD_INVITE].createButton = function ( ... )
    require "script/model/DataCache"
    local item= CCMenuItemImage:create("images/guild/invite/invite_n.png", "images/guild/invite/invite_h.png")
    item:registerScriptTapHandler(_itemArray[GUILD_INVITE].actionCallback)

    local newAnimSprite = XMLSprite:create("images/base/effect/yao/yao")
    newAnimSprite:setPosition(ccp(item:getContentSize().width/2,item:getContentSize().height/2))
    newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    item:addChild(newAnimSprite,-1)

    local button = createButtonWithItem(item)
    return button
end
_itemArray[GUILD_INVITE].actionCallback = function ( ... )
    require "script/ui/teamGroup/ReceiveInviteLayer"
    AudioUtil.playEffect("audio/effect/zhujiemian.mp3")
    local updateCallback = function ()
        require "script/ui/main/MainMenuLayer"
        MainMenuLayer.updateMiddleButton()
    end
    ReceiveInviteLayer.showLayer(updateCallback)
end
_itemArray[GUILD_INVITE].isShow = function ( ... )
    require "script/ui/teamGroup/TeamGroupData"
    local isShow = TeamGroupData.hasInviteMem()
    return isShow
end

--城池战
_itemArray[CITY_WAR] = {}
_itemArray[CITY_WAR].createButton = function ( ... )
    require "script/model/DataCache"
    local item= CCMenuItemImage:create("images/main/sub_icons/city_war_n.png", "images/main/sub_icons/city_war_h.png")
    item:registerScriptTapHandler(_itemArray[CITY_WAR].actionCallback)

    local newAnimSprite = XMLSprite:create("images/base/effect/yao/yao")
    newAnimSprite:setPosition(ccp(item:getContentSize().width*0.5,item:getContentSize().height/2))
    newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    item:addChild(newAnimSprite,-1)

    local button = createButtonWithItem(item)
    return button
end
_itemArray[CITY_WAR].actionCallback = function ( ... )
    require "script/ui/guild/city/CityData"
    CityData.setIsEnterCityTip(true)
    require "script/ui/copy/CityTipLayer"
    CityTipLayer.show()
end
_itemArray[CITY_WAR].isShow = function ( ... )
    require "script/ui/guild/city/CityData"
    local isShow = CityData.getMianBtnIsShow()
    return isShow
end

--神秘层
_itemArray[TOWER_MYSTERIOUS] = {}
_itemArray[TOWER_MYSTERIOUS].createButton = function ( ... )

    local item= CCMenuItemImage:create("images/main/sub_icons/mysterious_n.png", "images/main/sub_icons/mysterious_h.png")
    item:registerScriptTapHandler(_itemArray[TOWER_MYSTERIOUS].actionCallback)

    local newAnimSprite = XMLSprite:create("images/base/effect/yao/yao")
    newAnimSprite:setPosition(ccp(item:getContentSize().width/2,item:getContentSize().height/2))
    newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    item:addChild(newAnimSprite,-1)

    local button = createButtonWithItem(item)
    return button
end
_itemArray[TOWER_MYSTERIOUS].actionCallback = function ( ... )
    require "script/ui/tower/TowerMainLayer"
    local towerMainLayer = TowerMainLayer.createLayer()
    MainScene.changeLayer(towerMainLayer, "towerMainLayer")
end
_itemArray[TOWER_MYSTERIOUS].isShow = function ( ... )
    require "script/ui/tower/TowerCache"
    local isShow = TowerCache.haveOrNotSceret()
    return isShow
end

--抢粮战
_itemArray[ROB_BATTLE] = {}
_itemArray[ROB_BATTLE].createButton = function ( ... )

    local item=  CCMenuItemImage:create("images/guild_rob_list/tip_n.png", "images/guild_rob_list/tip_h.png")
    item:registerScriptTapHandler(_itemArray[ROB_BATTLE].actionCallback)

    local newAnimSprite = XMLSprite:create("images/base/effect/yao/yao")
    newAnimSprite:setPosition(ccp(item:getContentSize().width/2,item:getContentSize().height/2))
    newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    item:addChild(newAnimSprite,-1)

    local button = createButtonWithItem(item)
    return button
end
_itemArray[ROB_BATTLE].actionCallback = function ( ... )
    local handleGetGuildInfo = function( cbFlag, dictData, bRet )
        if dictData.err ~= "ok" then
            return
        end
        GuildDataCache.setGuildInfo(dictData.ret)
        local myGuildRobInfo = GuildRobData.getMyGuildRobInfo()
        if myGuildRobInfo.robId ~= nil and myGuildRobInfo.robId ~= 0 then
            GuildRobBattleLayer.show()
        end
    end
    RequestCenter.guild_getGuildInfo(handleGetGuildInfo)
end
_itemArray[ROB_BATTLE].isShow = function ( ... )
    require "script/ui/guild/guildRobList/GuildRobData"
    require "script/ui/guild/GuildDataCache"
    require "script/ui/guild/guildrob/GuildRobBattleLayer"
    local isShow = GuildRobData.isRobbing()
    return isShow
end

--国战
_itemArray[COUNTRY_WAR] = {}
_itemArray[COUNTRY_WAR].createButton = function ( ... )

    local item=  CCMenuItemImage:create("images/country_war/quick_btn_n.png", "images/country_war/quick_btn_h.png")
    item:registerScriptTapHandler(_itemArray[COUNTRY_WAR].actionCallback)

    local newAnimSprite = XMLSprite:create("images/base/effect/yao/yao")
    newAnimSprite:setPosition(ccp(item:getContentSize().width/2,item:getContentSize().height/2))
    newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    item:addChild(newAnimSprite,-1)

    local button = createButtonWithItem(item)
    return button
end
_itemArray[COUNTRY_WAR].actionCallback = function ( ... )
    require "script/ui/countryWar/CountryWarMainLayer"
    CountryWarMainLayer.show()
end
_itemArray[COUNTRY_WAR].isShow = function ( ... )
    require "script/ui/countryWar/CountryWarMainData"
    local isShow = CountryWarMainData.isShowQuickIcon()
    return isShow
end

--红包
_itemArray[RED_PACKAGEG] = {}
_itemArray[RED_PACKAGEG].createButton = function ( ... )

    local item=  CCMenuItemImage:create("images/redpacket/redicon1.png", "images/redpacket/redicon2.png")
    item:registerScriptTapHandler(_itemArray[RED_PACKAGEG].actionCallback)

    local newAnimSprite = XMLSprite:create("images/base/effect/yao/yao")
    newAnimSprite:setPosition(ccpsprite(0.5, 0.6, item))
    newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    item:addChild(newAnimSprite,-1)

    local button = createButtonWithItem(item)
    return button
end
_itemArray[RED_PACKAGEG].actionCallback = function ( ... )
    require "script/ui/rechargeActive/RechargeActiveMain"
    local monthSignLayer = RechargeActiveMain.create(RechargeActiveMain._tagRedPacket)
    MainScene.changeLayer(monthSignLayer,"monthSignLayer")
end
_itemArray[RED_PACKAGEG].isShow = function ( ... )
    require "script/ui/redpacket/RedPacketData"
    local isShow = RedPacketData.isShowRed()
    print("【RED_PACKAGEG】show:",isShow)
    return isShow
end

--木牛流马邀请
_itemArray[HORSE_INVITE] = {}
_itemArray[HORSE_INVITE].createButton = function ( ... )

    local item=  CCMenuItemImage:create("images/horse/invite.png", "images/horse/invite.png")
    item:registerScriptTapHandler(_itemArray[HORSE_INVITE].actionCallback)

    local newAnimSprite = XMLSprite:create("images/horse/mnlm_yao/mnlm_yao")
    newAnimSprite:setPosition(ccpsprite(0.5, 0.5, item))
    newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    item:addChild(newAnimSprite,-1)

    local button = createButtonWithItem(item)
    return button
end
_itemArray[HORSE_INVITE].actionCallback = function ( ... )
    require "script/ui/horse/HorseReceiveInviteLayer"
    HorseReceiveInviteLayer.showLayer(nil,-1000,1000)
end
_itemArray[HORSE_INVITE].isShow = function ( ... )
    require "script/ui/horse/HorseData"
    local isShow = HorseData.isHaveInvite()
    print("HORSE_INVITE:",isShow)
    return isShow
end

--装备称号失效
_itemArray[TITLE_DISAPPEAR] = {}
_itemArray[TITLE_DISAPPEAR].createButton = function ( ... )
    local item=  CCMenuItemImage:create("images/title/disappear_n.png", "images/title/disappear_h.png")
    item:registerScriptTapHandler(_itemArray[TITLE_DISAPPEAR].actionCallback)

    local newAnimSprite = XMLSprite:create("images/title/effect/shixiao/shixiao")
    newAnimSprite:setPosition(ccpsprite(0.5, 0.5, item))
    newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    item:addChild(newAnimSprite,-1)

    local button = createButtonWithItem(item)
    return button
end
_itemArray[TITLE_DISAPPEAR].actionCallback = function ( ... )
    require "script/ui/title/TitleDisappearDialog"
    local titleId = TitleData.getLastDisappearTitleId()
    TitleDisappearDialog.showDialog(titleId,-1000,1000)
end
_itemArray[TITLE_DISAPPEAR].isShow = function ( ... )
    require "script/ui/title/TitleData"
    local isShow = TitleData.isHadDisappearTitle()
    print("TITLE_DISAPPEAR:",isShow)
    return isShow
end

--资源库宝藏
_itemArray[RES_TREAS] = {}
_itemArray[RES_TREAS].createButton = function ( ... )
    local item=  CCMenuItemImage:create("images/main/round_btn/res_btn_n.png", "images/main/round_btn/res_btn_h.png")
    item:registerScriptTapHandler(_itemArray[RES_TREAS].actionCallback)

    local newAnimSprite = XMLSprite:create("images/main/round_effect/baozang/baozang")
    newAnimSprite:setPosition(ccpsprite(0.5, 0.5, item))
    newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
    item:addChild(newAnimSprite,-1)

    local button = createButtonWithItem(item)
    return button
end
_itemArray[RES_TREAS].actionCallback = function ( ... )
    require "script/ui/active/mineral/MineralLayer"
    local mineralLayer = MineralLayer.createLayer()
    MainScene.changeLayer(mineralLayer, "mineralLayer")
end
_itemArray[RES_TREAS].isShow = function ( ... )
    require "script/ui/active/mineral/MineralElvesData"
    local isShow = MineralElvesData.isShow()
    return isShow
end

-- --内置浏览器
-- _itemArray[WEB_VIEW] = {}
-- _itemArray[WEB_VIEW].createButton = function ( ... )
--     require "script/ui/web/WebViewModel"
--     local item= CCMenuItemImage:create("images/web/web_view_n.png", "images/web/web_view_h.png")
--     item:registerScriptTapHandler(_itemArray[WEB_VIEW].actionCallback)
--     local newAnimSprite = XMLSprite:create("images/base/effect/yao/yao");
--     newAnimSprite:setPosition(ccp(item:getContentSize().width*0.5,item:getContentSize().height/2+5))
--     newAnimSprite:setAnchorPoint(ccp(0.5,0.5))
--     item:addChild(newAnimSprite,-1)

--     local isShowTip = WebViewModel.getRedPoint()
--     showTipSprite(item,isShowTip)

--     _itemArray[WEB_VIEW].item = item

--     local button = createButtonWithItem(item)
--     return button
-- end
-- _itemArray[WEB_VIEW].actionCallback = function ( ... )
--     AudioUtil.playEffect("audio/effect/zhujiemian.mp3")
--     WebViewModel.requestWebViewData(function ( ... )
--         WebViewModel.showWebView()
--         local item = _itemArray[WEB_VIEW].item
--         if( item:getChildByTag(1915) ~= nil )then
--             local tipSprite = tolua.cast(item:getChildByTag(1915),"CCSprite")
--             tipSprite:setVisible(false)
--         end
--         WebViewModel.redPointState(false)
--     end)
-- end
-- _itemArray[WEB_VIEW].isShow = function ( ... )
    
--     local isShow = WebViewModel.isLimitShow()
--     return isShow  
-- end
-- 按钮上边的提示小红圈
-- 添加对象  item
-- isVisible 是否显示
function showTipSprite( item, isVisible )
    if(item == nil)then
        return
    end
    if( item:getChildByTag(1915) ~= nil )then
        local tipSprite = tolua.cast(item:getChildByTag(1915),"CCSprite")
        tipSprite:setVisible(isVisible)
    else
        local tipSprite = CCSprite:create("images/common/tip_2.png")
        tipSprite:setAnchorPoint(ccp(0.5,0.5))
        tipSprite:setPosition(ccp(item:getContentSize().width*0.8,item:getContentSize().height*0.8))
        item:addChild(tipSprite,1,1915)
        tipSprite:setVisible(isVisible)
    end
end

function createButton( pNorImg, pHigImg, pAction )
    local normalSprite = CCSprite:create(pNorImg)
    local highSprite   = CCSprite:create(pHigImg)

    local itemSprite = CCSprite:create()
    itemSprite:setContentSize(normalSprite:getContentSize())
    itemSprite:setAnchorPoint(ccp(0.5, 0.5))
    local menu = CCMenu:create()
    menu:setContentSize(itemSprite:getContentSize())
    menu:setAnchorPoint(ccp(0.5, 0.5))
    menu:setPosition(ccpsprite(0.5, 0.5, itemSprite))
    menu:ignoreAnchorPointForPosition(false)
    itemSprite:addChild(menu)

    local item = CCMenuItemSprite:create(normalSprite, highSprite)
    item:setAnchorPoint(ccp(0.5, 0.5))
    item:setPosition(ccpsprite(0.5, 0.5, menu))
    item:registerScriptTapHandler(pAction)
    menu:addChild(item, 80)
    return itemSprite
end

function createButtonWithItem( pItem )
    local itemSprite = CCSprite:create()
    itemSprite:setContentSize(pItem:getContentSize())
    itemSprite:setAnchorPoint(ccp(0.5, 0.5))

    local menu = CCMenu:create()
    menu:setContentSize(itemSprite:getContentSize())
    menu:setAnchorPoint(ccp(0.5, 0.5))
    menu:setPosition(ccpsprite(0.5, 0.5, itemSprite))
    menu:ignoreAnchorPointForPosition(false)
    itemSprite:addChild(menu)

    pItem:setAnchorPoint(ccp(0.5, 0.5))
    pItem:setPosition(ccpsprite(0.5, 0.5, menu))
    menu:addChild(pItem)

    return itemSprite
end




